﻿Imports System.Data.SqlClient
Public Class frm_show_room_type


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        showForm(frm_roomType)
    End Sub
    Private Sub showForm(ByVal form As Form)
        form.Show()
    End Sub
    Private Sub LoadData()
        Try
            Dim cn As New SqlConnection
            cn.ConnectionString = "SERVER = .; USER = sa; PASSWORD = 123; DATABASE = HOTELMANAGEMENT;"
            cn.Open()
            'MessageBox.Show("connect")

            Dim cmd As New SqlCommand()
            cmd.Connection = cn
            cmd.CommandText = "Select * from TblRoomType"

            'Dim cmd As New SqlCommand("SELECT tr.RoomID, rt.RoomType, rp.RoomPrice, tr.Floor, tr.RoomAdditional FROM TblRooms as tr, TblRoomType as rt, TblRoomPrice as rp WHERE tr.RoomTypeID = rt.RoomTypeID AND tr.RoomPriceID = rp.RoomPriceID", cn)

            Dim reader = cmd.ExecuteReader()
            Dim dt As New DataTable
            dt.Load(reader)
            reader.Close()
            Me.DataGridView1.DataSource = dt

        Catch ex As Exception
            MessageBox.Show(ex.ToString)

        End Try
    End Sub


    Private Sub frm_show_room_type_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadData()

    End Sub

    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

    End Sub
End Class